﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using Extra.ERP;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_PROCESS_BREAKWORK
    {
        private Guid m_BreakWorkID;
        private DateTime m_Date;
        private string m_Description;
        private string m_EmployeeCode;
        private DateTime m_FromDate;
        private string m_Person;
        private string m_Reason;
        private DateTime m_ToDate;

        public HRM_PROCESS_BREAKWORK()
        {
            this.m_BreakWorkID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_FromDate = DateTime.Now;
            this.m_ToDate = DateTime.Now;
            this.m_Reason = "";
            this.m_Date = DateTime.Now;
            this.m_Person = "";
            this.m_Description = "";
        }

        public HRM_PROCESS_BREAKWORK(Guid BreakWorkID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Reason, DateTime Date, string Person, string Description)
        {
            this.m_BreakWorkID = BreakWorkID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_FromDate = FromDate;
            this.m_ToDate = ToDate;
            this.m_Reason = Reason;
            this.m_Date = Date;
            this.m_Person = Person;
            this.m_Description = Description;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@BreakWorkID" };
            object[] myValues = new object[] { this.m_BreakWorkID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_BREAKWORK_Delete", myParams, myValues);
        }

        public string Delete(Guid BreakWorkID)
        {
            string[] myParams = new string[] { "@BreakWorkID" };
            object[] myValues = new object[] { BreakWorkID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_BREAKWORK_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid BreakWorkID)
        {
            string[] myParams = new string[] { "@BreakWorkID" };
            object[] myValues = new object[] { BreakWorkID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_BREAKWORK_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid BreakWorkID)
        {
            string[] myParams = new string[] { "@BreakWorkID" };
            object[] myValues = new object[] { BreakWorkID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_BREAKWORK_Delete", myParams, myValues);
        }

        public string DeleteByMonth(string EmployeeCode, int Month, int Year)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Month", "@Year" };
            object[] myValues = new object[] { EmployeeCode, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_BREAKWORK_DeleteByMonth", myParams, myValues);
        }

        public bool Exist(Guid BreakWorkID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@BreakWorkID" };
            object[] myValues = new object[] { BreakWorkID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_BREAKWORK_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid BreakWorkID)
        {
            string str = "";
            string[] myParams = new string[] { "@BreakWorkID" };
            object[] myValues = new object[] { BreakWorkID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_BREAKWORK_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_BreakWorkID = reader.GetGuid(reader.GetOrdinal("BreakWorkID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid BreakWorkID)
        {
            string str = "";
            string[] myParams = new string[] { "@BreakWorkID" };
            object[] myValues = new object[] { BreakWorkID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_PROCESS_BREAKWORK_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_BreakWorkID = reader.GetGuid(reader.GetOrdinal("BreakWorkID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid BreakWorkID)
        {
            string str = "";
            string[] myParams = new string[] { "@BreakWorkID" };
            object[] myValues = new object[] { BreakWorkID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_PROCESS_BREAKWORK_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_BreakWorkID = reader.GetGuid(reader.GetOrdinal("BreakWorkID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetAllList()
        {
            int num = 0;
            string branchCode = "";
            SYS_USER sys_user = new SYS_USER();
            sys_user.GetUserName(MyLogin.Account);
            if (sys_user.Management == 0)
            {
                num = 0;
                branchCode = "";
            }
            else if (sys_user.Management == 1)
            {
                num = 1;
                branchCode = sys_user.BranchCode;
            }
            else if (sys_user.Management == 2)
            {
                num = 2;
                branchCode = sys_user.DepartmentCode;
            }
            else if (sys_user.Management == 3)
            {
                num = 3;
                branchCode = sys_user.GroupCode;
            }
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { num, branchCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_BREAKWORK_GetAllList", myParams, myValues);
        }

        public DataTable GetAllListByDays(DateTime BeginDate, DateTime EndDate)
        {
            int num = 0;
            string branchCode = "";
            SYS_USER sys_user = new SYS_USER();
            sys_user.GetUserName(MyLogin.Account);
            if (sys_user.Management == 0)
            {
                num = 0;
                branchCode = "";
            }
            else if (sys_user.Management == 1)
            {
                num = 1;
                branchCode = sys_user.BranchCode;
            }
            else if (sys_user.Management == 2)
            {
                num = 2;
                branchCode = sys_user.DepartmentCode;
            }
            else if (sys_user.Management == 3)
            {
                num = 3;
                branchCode = sys_user.GroupCode;
            }
            string[] myParams = new string[] { "@Level", "@Code", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { num, branchCode, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_BREAKWORK_GetAllListByDays", myParams, myValues);
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_BREAKWORK_GetList");
        }

        public DataTable GetListByDays(string EmployeeCode, DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { EmployeeCode, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_BREAKWORK_GetListByDays", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_BREAKWORK_GetListByEmployee", myParams, myValues);
        }

        public DataTable GetListByMonth(string EmployeeCode, int Month, int Year)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Month", "@Year" };
            object[] myValues = new object[] { EmployeeCode, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_BREAKWORK_GetListByMonth", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@BreakWorkID", "@EmployeeCode", "@FromDate", "@ToDate", "@Reason", "@Date", "@Person", "@Description" };
            object[] myValues = new object[] { this.m_BreakWorkID, this.m_EmployeeCode, this.m_FromDate, this.m_ToDate, this.m_Reason, this.m_Date, this.m_Person, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_BREAKWORK_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@BreakWorkID", "@EmployeeCode", "@FromDate", "@ToDate", "@Reason", "@Date", "@Person", "@Description" };
            object[] myValues = new object[] { this.m_BreakWorkID, this.m_EmployeeCode, this.m_FromDate, this.m_ToDate, this.m_Reason, this.m_Date, this.m_Person, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_BREAKWORK_Insert", myParams, myValues);
        }

        public string Insert(Guid BreakWorkID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Reason, DateTime Date, string Person, string Description)
        {
            string[] myParams = new string[] { "@BreakWorkID", "@EmployeeCode", "@FromDate", "@ToDate", "@Reason", "@Date", "@Person", "@Description" };
            object[] myValues = new object[] { BreakWorkID, EmployeeCode, FromDate, ToDate, Reason, Date, Person, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_BREAKWORK_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid BreakWorkID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Reason, DateTime Date, string Person, string Description)
        {
            string[] myParams = new string[] { "@BreakWorkID", "@EmployeeCode", "@FromDate", "@ToDate", "@Reason", "@Date", "@Person", "@Description" };
            object[] myValues = new object[] { BreakWorkID, EmployeeCode, FromDate, ToDate, Reason, Date, Person, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_BREAKWORK_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid BreakWorkID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Reason, DateTime Date, string Person, string Description)
        {
            string[] myParams = new string[] { "@BreakWorkID", "@EmployeeCode", "@FromDate", "@ToDate", "@Reason", "@Date", "@Person", "@Description" };
            object[] myValues = new object[] { BreakWorkID, EmployeeCode, FromDate, ToDate, Reason, Date, Person, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_BREAKWORK_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_PROCESS_BREAKWORK", "JobCode", "CV");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@BreakWorkID", "@EmployeeCode", "@FromDate", "@ToDate", "@Reason", "@Date", "@Person", "@Description" };
            object[] myValues = new object[] { this.m_BreakWorkID, this.m_EmployeeCode, this.m_FromDate, this.m_ToDate, this.m_Reason, this.m_Date, this.m_Person, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_BREAKWORK_Update", myParams, myValues);
        }

        public string Update(Guid BreakWorkID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Reason, DateTime Date, string Person, string Description)
        {
            string[] myParams = new string[] { "@BreakWorkID", "@EmployeeCode", "@FromDate", "@ToDate", "@Reason", "@Date", "@Person", "@Description" };
            object[] myValues = new object[] { BreakWorkID, EmployeeCode, FromDate, ToDate, Reason, Date, Person, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_BREAKWORK_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid BreakWorkID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Reason, DateTime Date, string Person, string Description)
        {
            string[] myParams = new string[] { "@BreakWorkID", "@EmployeeCode", "@FromDate", "@ToDate", "@Reason", "@Date", "@Person", "@Description" };
            object[] myValues = new object[] { BreakWorkID, EmployeeCode, FromDate, ToDate, Reason, Date, Person, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_BREAKWORK_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid BreakWorkID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Reason, DateTime Date, string Person, string Description)
        {
            string[] myParams = new string[] { "@BreakWorkID", "@EmployeeCode", "@FromDate", "@ToDate", "@Reason", "@Date", "@Person", "@Description" };
            object[] myValues = new object[] { BreakWorkID, EmployeeCode, FromDate, ToDate, Reason, Date, Person, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_BREAKWORK_Update", myParams, myValues);
        }

        [Category("Primary Key"), DisplayName("BreakWorkID")]
        public Guid BreakWorkID
        {
            get
            {
                return this.m_BreakWorkID;
            }
            set
            {
                this.m_BreakWorkID = value;
            }
        }

        [Category("Column"), DisplayName("Date")]
        public DateTime Date
        {
            get
            {
                return this.m_Date;
            }
            set
            {
                this.m_Date = value;
            }
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [Category("Column"), DisplayName("EmployeeCode")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [DisplayName("FromDate"), Category("Column")]
        public DateTime FromDate
        {
            get
            {
                return this.m_FromDate;
            }
            set
            {
                this.m_FromDate = value;
            }
        }

        [DisplayName("Person"), Category("Column")]
        public string Person
        {
            get
            {
                return this.m_Person;
            }
            set
            {
                this.m_Person = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_PROCESS_BREAKWORK";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Column"), DisplayName("Reason")]
        public string Reason
        {
            get
            {
                return this.m_Reason;
            }
            set
            {
                this.m_Reason = value;
            }
        }

        [DisplayName("ToDate"), Category("Column")]
        public DateTime ToDate
        {
            get
            {
                return this.m_ToDate;
            }
            set
            {
                this.m_ToDate = value;
            }
        }
    }
}

